﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UserNotificationTrigger.cs" company="YellowFish">
//   Copyright © YellowFish 2009
// </copyright>
// <summary>
//   Defines what event activates a notification.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MobilePal.WindowsNative.Notification
{
  #region Imported Namespaces


  using System;
  using System.Runtime.InteropServices;


  #endregion


  /// <summary>
  /// Defines what event activates a notification.
  /// </summary>
  [StructLayout(LayoutKind.Sequential)]
  public class UserNotificationTrigger
  {
    internal int dwSize = 0x34;
    private int dwType;
    private int dwEvent;

    [MarshalAs(UnmanagedType.LPWStr)]
    private string lpszApplication = string.Empty;

    [MarshalAs(UnmanagedType.LPWStr)]
    private string lpszArguments;

    internal SYSTEMTIME stStartTime;
    internal SYSTEMTIME stEndTime;

    /// <summary>
    /// Specifies the type of notification.
    /// </summary>
    public NotificationType Type
    {
      get
      {
        return (NotificationType)dwType;
      }

      set
      {
        dwType = (int)value;
      }
    }

    /// <summary>
    /// Specifies the type of event should Type = Event.
    /// </summary>
    public NotificationEvent Event
    {
      get
      {
        return (NotificationEvent)dwEvent;
      }

      set
      {
        dwEvent = (int)value;
      }
    }

    /// <summary>
    /// Name of the application to execute.
    /// </summary>
    public string Application
    {
      get
      {
        return lpszApplication;
      }

      set
      {
        lpszApplication = value;
      }
    }

    /// <summary>
    /// Command line (without the application name). 
    /// </summary>
    public string Arguments
    {
      get
      {
        return lpszArguments;
      }

      set
      {
        lpszArguments = value;
      }
    }

    /// <summary>
    /// Specifies the beginning of the notification period.
    /// </summary>
    public DateTime StartTime
    {
      get
      {
        return stStartTime.ToDateTime();
      }

      set
      {
        stStartTime = SYSTEMTIME.FromDateTime(value);
      }
    }

    /// <summary>
    /// Specifies the end of the notification period. 
    /// </summary>
    public DateTime EndTime
    {
      get
      {
        return stEndTime.ToDateTime();
      }

      set
      {
        stEndTime = SYSTEMTIME.FromDateTime(value);
      }
    }
  }
}